# KRTS内核层代码
project(PluginDemo)

# 设置策略CMP0091为NEW，新策略 用于MT/MD等编译选项的配置
if(POLICY CMP0091)
    cmake_policy(SET CMP0091 NEW)
endif(POLICY CMP0091)

include_directories(.)
include_directories(..)

# 配置生成的执行文件、静态库、动态库保存位置
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${BUILD_LIB_DIR}/plugin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${BUILD_LIB_DIR}/plugin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BUILD_BIN_DIR}/plugin)

# 链接库
if (MSVC)
    # 配置忽略库
    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -NODEFAULTLIB:oldnames.lib")
endif ()

add_definitions(
        -DPLUGIN_DLL
)

# 生成动态库
add_library(${PROJECT_NAME} SHARED
        PluginDemo.cpp
        Kithara.cpp
)

# 链接依赖库
if(WIN32)
    target_link_libraries(${PROJECT_NAME} PUBLIC
            ${KITHARA_LIB}
    )
endif()

# 设置MT/MTd
set_property(TARGET ${PROJECT_NAME} PROPERTY
        MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")

# 设置编译选项
if (MSVC)
    set_target_properties(${PROJECT_NAME} PROPERTIES
            COMPILE_FLAGS "/EHsc"
    )
endif ()

# 复制文件到指定目录
